package String;

public class _345_ReverseVowelsofaString {
    public String reverseVowels(String s) {
        int length = s.length();
        int left = 0,right = length-1;
        char[] c = s.toCharArray();
        while (left < right) {
            System.out.println("l:"+c[left]);
            if (isVowel(c[left])) {
                while (right > left) {
                    if (isVowel(c[right])) {
                        System.out.println("r:"+c[right]);
                        char temp = c[right];
                        c[right] = c[left];
                        c[left] = temp;
                        right--;
                        break;
                    }
                    right--;
                }
            }
            left++;
        }
        return new String(c);
    }

    public boolean isVowel(char c){
        switch(c){
            case ('a') : return true;
            case ('e') : return true;
            case ('i') : return true;
            case ('o') : return true;
            case ('u') : return true;
            case ('A') : return true;
            case ('E') : return true;
            case ('I') : return true;
            case ('O') : return true;
            case ('U') : return true;
            default : return false;
        }
    }
}
